﻿@using DormMS.Model
@{
    Layout = "";
}
@model Member
<div  ng-controller="SignController">
    <div class="w_sign">
        <!-- 轮播图 -->
        <div>
            <carousel interval="myInterval">
                <slide ng-repeat="slide in slides" active="slide.active">
                    <a href="{{slide.url}}"><img ng-src="{{slide.image}}" style="margin: auto;" alt="" /></a>
                </slide>
            </carousel>
        </div>
        <!-- 轮播图结束 -->
        <ul class="w_sign_topMenu">
            <li class="w_sign_topMnLi1">
                <p>我的积分&nbsp;&nbsp;<font color="#eb272a">{{Model.Points}}</font></p>
            </li>
            <li class="w_sign_topMnLi2" ng-click="$state.go('user.pointDetail')">
                <a><p>积分兑换记录</p></a>
            </li>
        </ul>
        <ul class="w_signMid_menu">
            <li>
                    <div class="w_signMid_img"><img src="/Content/images/w_69.png" class="w_signMid_flag1" /></div>
                    <p>全部商品</p>
                    <div class="w_sign_line1"></div>
            </li>
            <li class="w_signClick" ng-click="membersign()">
                <div class="w_signMid_img"><img src="/Content/images/w_70.png" class="w_signMid_flag2" /></div>
                <p>签到领积分</p>
            </li>
            <li>
                <div ui-sref="draw.index">
                    <div class="w_signMid_img"><img src="/Content/images/w_71.png" class="w_signMid_flag3" /></div>
                    <p>积分抽奖</p>
                    <div class="w_sign_line2"></div>
                </div>
            </li>
        </ul>
        <div class="w_sign_main" infinite-scroll='reddit.nextPage()' infinite-scroll-disabled='reddit.busy' infinite-scroll-distance='0'>
            <section class="list_m_mdv srp">
                <div class="tile_box prolist1">
                    <div class="tile_item" ng-repeat="item in reddit.items">
                        <div class="ti_img_wrap ">
                            <img ng-src="{{ImgHostUrl+item.ImgUrl}}" class="ti_img">
                        </div>
                        <div class="ti_info">
                            <p class="tii_title" ui-sref="shop.productexchangedetail({Id:item.Id})">{{item.Name}}</p>
                            <div class="tii_price"><span class="w_sign_jfjf">{{item.Points}}积分</span><span ui-sref="shop.productexchangedetail({Id:item.Id})" class="w_sign_dhSub">兑换</span></div>
                        </div>
                    </div>
                </div>
            </section>
            <div class="clear"></div>
        </div>
    </div>

    <!--签到弹出-->
    <div class="w_pcGray" ng-show="signShow"></div>
    <div class="w_signPop"  ng-show="signShow">
        <div class="w_signPop_img"><img src="/Content/images/w_75.png" /></div>
        <p class="w_signPop_close" ng-click="signClose()"><img src="/Content/images/w_76.png" /></p>
        <div class="w_signPop_congr">恭喜你签到获取</div>
        <p class="w_signPop_jf"><big>@ViewBag.SignPoint</big>&nbsp;积分</p>
        <ul class="w_signPop_ul">
            <li>
                <span>今日签到</span>
                <label>+@(ViewBag.SignPoint)</label>
            </li>
            <li>
                <span>连续签到</span>
                <label>{{signDays}}天</label>
            </li>
        </ul>
    </div>

</div>

<script type="text/javascript">

		$(function(){
          var wh =$(window).height();
          //$(".f_popBox").css({height: wh, });


          jQuery.fn.center = function (loaded) {
                var obj = this;
                body_width = parseInt($(window).width());
                body_height = parseInt($(window).height());
                block_width = parseInt(obj.width());
                block_height = parseInt(obj.height());

                left_position = parseInt((body_width / 2) - (block_width / 2) + $(window).scrollLeft());
                if (body_width < block_width) {
                    left_position = 0 + $(window).scrollLeft();
                };

                top_position = parseInt((body_height / 2) - (block_height / 2) + $(window).scrollTop());
                if (body_height < block_height) {
                    top_position = 0 + $(window).scrollTop();
                };
                //                ($(window).height() - $('#code').height()) * 0.5
                if (!loaded) {

                    obj.css({
                        'position': 'absolute'
                    });
                    obj.css({
                        'top': top_position,
                        'left': left_position
                    });
                    $(window).bind('resize', function () {
                        obj.center(!loaded);
                    });
                    $(window).bind('scroll', function () {
                        obj.center(!loaded);
                    });

                } else {
                    obj.stop();
                    obj.css({
                        'position': 'absolute'
                    });
                    obj.animate({
                        'top': top_position
                    }, 200, 'linear');
                }
            }
          $('.w_signPop').center();
		});

		//$(".w_signPop_close").click(function(){
		//	$(".w_pcGray").hide();
		//	$(".w_signPop").hide();
		//});
		//$(".w_signClick").click(function(){
		//	$(".w_pcGray").show();
		//	$(".w_signPop").show();
		//});

		App.controller('SignController', [
            '$scope', '$state', '$route', '$http','Reddit','$rootScope',
                function ($scope, $state, $route, $http, Reddit, $rootScope) {

                    $scope.reddit = new Reddit("/UserCenter/GetProductExchange", { Take: 6 }, function (response) { });
                    console.log($scope.reddit);

                    $http.post("/UserCenter/GetCarousel").then(function (response) {
                        $scope.CarouselList = response.data.data;
                        // 设置轮播图图片间隔
                        $scope.myInterval = 3000;
                        // 轮播图数据初始化
                        var slides = $scope.slides = [];
                        // 添加轮播图源
                        if ($scope.CarouselList.length > 0) {
                            angular.forEach($scope.CarouselList, function (imgurl) {
                                slides.push({ image: $rootScope.ImgHostUrl + imgurl.ImgUrl, url: imgurl.LinkUrl });
                            });
                        }
                    });

                    var getMemberInfo = function () {
                        $http.post("/UserCenter/GetMemberInfo").then(function (response) {
                            layer.closeAll('loading');
                            if (response.data.isSuccess) {
                                $scope.Model = angular.copy(response.data.data);
                            }

                        });
                    }
                    getMemberInfo();
                    $rootScope.WxShare($rootScope.pageTitle(), '优品三悦', location.href, "");
                    $scope.signShow = false;
                    $scope.signDays = 1;

                    $scope.membersign = function () {
                        layer.load(2);
                        $http.post("/UserCenter/MemberSign").then(function (returnData) {
                            layer.closeAll('loading');
                            if (returnData.data.isSuccess) {
                                $scope.signShow = true;
                                $scope.signDays = returnData.data.data
                                getMemberInfo();
                            } else {
                                layer.msg(returnData.data.msg);
                            }
                        });
                    }


                    $scope.signClose = function () {
                        $scope.signShow = false;
                    }

                }
		]);
</script>
